
# add the binary tree to the search path for include files
# so that we will find ver.h
include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" "${POPT_INCLUDES}")

set (HEADERS "${PROJECT_BINARY_DIR}/config.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/contrib/cJSON.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/contrib/CJsonObject.hpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/contrib/tinyxml2.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/CodeGen.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/Generator.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/JsonClassGenerator.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/JsonNode.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/Node.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/Symbols.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/XmlClassGenerator.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/util.h")

set (SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/contrib/cJSON.c"
             "${CMAKE_CURRENT_SOURCE_DIR}/contrib/CJsonObject.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/contrib/tinyxml2.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/CodeGen.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/Generator.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/JsonClassGenerator.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/JsonNode.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/Node.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/Symbols.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/XmlClassGenerator.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/util.cpp")

# add the executable
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})
#link_directories("${PROJECT_SOURCE_DIR}/rutil" "${PROJECT_SOURCE_DIR}/popt")
target_link_libraries(${PROJECT_NAME} rutil ${POPT_LIBRARIES})
add_definitions(-DUSE_RUTIL_DATA)

if(MSVC)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
    # ws2_32.lib @ windows socket library
    # winmm.lib @ import timeGetTime
    target_link_libraries(${PROJECT_NAME} ws2_32 winmm)
else()
    # pthread @ windows socket library
    target_link_libraries(${PROJECT_NAME} pthread)
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -g -ggdb")
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wall")
endif()

# add the install targets
install (TARGETS ${PROJECT_NAME} DESTINATION bin)